package com.devehx.wallet.comm;

import lombok.Data;

/**
 * anther : hux
 * datetime : 2019/9/7 15:25
 * description :
 */
@Data
public class Result<T> {

    // 20

    /**
     * 状态码
     */
    private int code;

    /**
     * 数据
     */
    private T data;

    /**
     * 提示信息
     */
    private String message;

    public static <T> Result<T> no() {
        return custom(0, null, null);
    }

    public static <T> Result<T> no(String message) {
        return custom(0, message, null);
    }


    public static <T> Result<T> ok() {
        return custom(1, null, null);
    }

    public static <T> Result<T> ok(T data) {
        return custom(1, null, data);
    }

    public static <T> Result<T> custom(Integer code, String message, T data) {
        Result<T> r = new Result<>();
        r.code = code;
        r.data = data;
        r.message = message;
        return r;
    }

}
